package com.example.controller;

import com.example.domain.ResponseResult;
import com.example.domain.entity.QuestionAnswer;
import com.example.service.QuestionAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/questionAnswer")
public class QuestionAnswerController {
    @Autowired
    private QuestionAnswerService questionAnswerService;

    @GetMapping ("/getQAListByQuestionId/{questionId}")
    public ResponseResult getQAListByQid(@PathVariable Long questionId){
        return ResponseResult.okResult(questionAnswerService.getQAList(questionId));
    }


    /** 添加解答帖时（如果是专门为某个帖子的解答），要添加 求助-解答 关系 */
    @PostMapping("/add")
    public void addQuestionAnswer(@RequestBody QuestionAnswer questionAnswer){
        questionAnswerService.addQuestionAnswer(questionAnswer);
    }
}
